#include "RenderPch.h"

#include "Font.h"
#include <stdio.h>

Font::Font(void)
: m_lpFont( NULL )
{
	memset( &m_FontDesc, 0, sizeof( m_FontDesc ) );
}

Font::~Font(void)
{
	if( m_lpFont )
	{
		m_lpFont->Release();
		m_lpFont = NULL;
	}
}

void Font::RenderText( const LONG& lPosX, const LONG& lPosY, const char* pcFormat, ... )
{
	char acBuf[ 512 ] = {0,};

	va_list lst;
	va_start( lst, pcFormat );
	sprintf_s( acBuf, sizeof( char ) * 512, pcFormat, sizeof( char ) * ( strlen( pcFormat ) + 1 ) );
	
	va_end( lst );
	if( m_lpFont )
	{
		RECT rc;
		rc.left = lPosX;
		rc.top = lPosY;

		m_lpFont->DrawText( NULL, acBuf, strlen( acBuf ), &rc, DT_NOCLIP, 0xffffffff );
	}
}

void Font::RenderTextDirect( const LONG& lPosX, const LONG& lPosY, const char* pBuf )
{
	if( m_lpFont )
	{
		RECT rc;
		rc.left = lPosX;
		rc.top = lPosY;

		m_lpFont->DrawText( NULL, pBuf, strlen( pBuf ), &rc, DT_NOCLIP, 0xff000000 );
	}
}
